import window from ".";
import { getAntd,getLabel } from './convert';
import {WeaTools} from 'ecCom';

const modeForm_pc = {
    showMessage: function(msg, type=1, duration=1.5){
        const message = WeaTools.WindowFunc.getTop().antd.message;
        if(type === 1)      //警告
            message.warning(msg, duration);
        else if(type === 2)     //错误
            message.error(msg, duration);
        else if(type === 3)     //成功
            message.success(msg, duration);
        else    //普通信息
            message.info(msg, duration);
    },
    showConfirm: function(content, okEvent, cancelEvent, otherInfo:any={}){
        const { Modal } = getAntd();
        Modal.confirm({
            title: otherInfo.title || getLabel(131329,'信息确认'),
            content: window.React.createElement("div", {dangerouslySetInnerHTML:{__html:content}}),
            okText: otherInfo.okText || getLabel(826,'确定'),
            cancelText: otherInfo.cancelText || getLabel(201,'取消'),
            onOk() {
                typeof okEvent === "function" && okEvent();
            },
            onCancel() {
                typeof cancelEvent === "function" && cancelEvent();
            },
        });
    },
    getCurrentUserInfo:function(){
        return window.ecCom.WeaTools.ls.getJSONObj('theme-account');
    },
    showModalMsg: function(title,msg,type= 1){
        const { Modal } = getAntd();
        let typeName = "info";
        if(type === 1)      //普通信息
            typeName = "info";
        else if(type === 2)     //错误
            typeName = "error";
        else if(type === 3)     //成功
            typeName = "success";
        else    //警告
            typeName = "warning";

        Modal[typeName]({
            title: title ||"",
            content: <div dangerouslySetInnerHTML={{__html:msg}}></div>,
        });
    },
}

export {modeForm_pc};